﻿using ProjectResistance.Shell.Controllers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading;

namespace ProjectResistance.Unit.Test
{
    [TestClass()]
    public class ResistorControllerTest
    {
        public TestContext TestContext { get; set; }

        [TestMethod()]
        [Description("Ensures that a ResistorController can be created")]
        public void ControllerCtorPositiveTest()
        {
            ResistorController controller = new ResistorController();
            Assert.IsNotNull(controller, "ctor returned null");

        }

        [TestMethod()]
        [Description("Ensures that when we call SetResistance, the ResistanceChanged event fires")]
        public void ResistanceChangedEventTest()
        {
            AutoResetEvent are = new AutoResetEvent(false);
            ResistorController controller = new ResistorController();
            controller.ResistanceChanged += delegate
            {
                are.Set();
            };

            controller.SetResistance(100);
            Assert.IsTrue(are.WaitOne(1000, false), "Event did not fire");
        }

    }
}
